package ch.dungegondefenders.appstates;

import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.input.KeyEvent;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import ch.dungegondefenders.DFConsts;

/**
 * Main Intro AppState.
 */
public class AppStateIntro extends AbstractAppState {
	private Group root;

	public AppStateIntro(AppStateManager manager) {
		super(manager);
	}

	@Override
	public Scene createScene() {
		root = new Group();

		Scene scene = new Scene(root, DFConsts.SCREEN_X, DFConsts.SCREEN_Y,
				true);
		scene.setFill(Color.YELLOW);

		createUI();

		return scene;
	}

	/**
	 * creates the UI .
	 */
	private void createUI() {
		VBox vert = new VBox();
		vert.setTranslateX(DFConsts.SCREEN_X / 2);
		vert.setTranslateY(DFConsts.SCREEN_Y / 2);
		root.getChildren().add(vert);

		// dummy text
		Text txt = new Text("Intro");

		txt.setFont(new Font(30));
		vert.getChildren().add(txt);
	}

	/**
	 * creates the Tag Clouds based on the data provided.
	 */
	@Override
	public void activate() {

	}

	@Override
	public void exit() {

	}

	@Override
	public void init() {
		super.init();
		// any key switches to menu
		scene.setOnKeyPressed(new EventHandler<KeyEvent>() {
			public void handle(KeyEvent event) {
				manager.switchTo(AppStates.MENU);
			}
		});
	}
}
